//Point.h
#ifndef _POINT_H
#define _POINT_H
class Point{      //基类Point类的定义
public:
    void initPoint(float x=0,float y=0) {this -> x=x;this -> y=y;}
    void move(float offX,float offY) {x+=offX;y+=offY;}
    float getX() const {return x;}
    float getY() const {return y;}
private:				//私有数据成员
    float x,y;
};
#endif    //_POINT_H

//Rectangle.h
#ifndef _RECTANGLE_H
#define _RECTANGLE_H
#include "Point.h"
class Rectangle:public Point{		//派生类的定义
public:								//新增公有函数成员
    void initRectangle(float x, float y, float w, float h) {
        initPoint(x, y);
        this -> w = w;
        this -> h = h;
    }
    float getH() const {return h;}
    float getW() const {return w;}
private:						//新增私有数据成员
    float w,h;
};
#endif                            //_Rectangle_H

#include<iostream>
#include<cmath>
#include "Rectangle.h"
using namespace std;

int main(){
    Rectangle rect(2, 3, 20, 10);
    rect.move(3, 2);
    cout << "The data of rect(x,y,w,h):" << endl;
    cout << rect.getX() << "," << rect.getY() << "," << rect.getW() << "," << rect.getH() << endl;
    return 0;
}
